from appium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

desired_caps = {
    'platformName':'Android',
    'platformVersion': '7.1.2',
    'deviceName': 'emulator-5554',
    'appPackage': 'com.android.settings',
    'appActivity': '.Settings'
}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
time.sleep(1)
driver.implicitly_wait(10)

# # ⚠️从一个坐标位置滑动到另一个坐标位置,只能是两个点之间的滑动
# #   方法：swipe(start_x, start_y, end_x, end_y, duration=None)
# for i in range(3):
#     driver.swipe(450, 1500, 450, 440, 500)
#     time.sleep(2)

# # ⚠️ 从一个元素滑动到另一个元素，直到页面自动停止
# #   方法：scroll(origin_el, destination_el)
# start_ele = driver.find_element(By.XPATH, '//*[@text="更多"]')
# end_ele = driver.find_element(By.XPATH, '//*[@text="建议"]')
# driver.scroll(start_ele, end_ele)

# # 应用置于后台事件
# driver.background_app(5)

time.sleep(5)
driver.quit()